package com.brilliance.project.service.sample.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.brilliance.project.dao.ISampleDao;
import com.brilliance.project.dao.entity.Sample;
import com.brilliance.project.service.sample.ISampleService;
import com.brilliance.project.webapp.form.sample.SampleForm;

@Component("sampleSeviceImpl")
public class SampleSeviceImpl implements ISampleService {
	
	@Autowired
	private ISampleDao sampleDaoImpl;
//	@Override
//	public String test(String name) {
//		sampleDaoImpl.getSample("1");
//		return name+" 进了SampleServiceImpl";
//	}
	
	public List<SampleForm> query(SampleForm sampleForm){
		return sampleDaoImpl.query(sampleForm);
	}
	
	public String test(String name) throws Exception{
		List<Sample> list = new ArrayList<Sample>();
		Sample s1 = new Sample();
		s1.setId(1);
		s1.setName("h1");
		s1.setMemo("h1memo");
		list.add(s1);
		
		Sample s2 = new Sample();
		s2.setId(2);
		s2.setName("h2");
		s2.setMemo("h2memo");
		list.add(s2);
		
		Sample s3 = new Sample();
		s3.setId(11);
		s3.setName(null);
		s3.setMemo("h3memo");
		list.add(s3);
		
		System.out.println(sampleDaoImpl.addSample(list));
		return "a";
	}
	
	
	//---getter and setter---//
	
	public ISampleDao getSampleDaoImpl() {
		return sampleDaoImpl;
	}
	public void setSampleDaoImpl(ISampleDao sampleDaoImpl) {
		this.sampleDaoImpl = sampleDaoImpl;
	}

}
